pro jtprob, ps = ps

  COMPILE_OPT OBSOLETE
  
  restore, file = './local/l032.xmatch.dat'
  for i = 0, n_elements(s3)-1 do begin
    s = s3[i]

    p1 = prob_lonlat(s.glon, s.glat)
    p2 = prob_kdist(s.glon, s.glat, s.vlsr)
    p3 = prob_irdc(s.glon, s.glat)
;    p4 = prob_grsmatch2(s)
    p4a = prob_grsmatch(s)
    p = p1*p2*p3*p4
    p = p/total(p)

    dvec = findgen(1000)*20
    probeval, dvec, p, distance = disteval

    
  if keyword_set(ps) then ps, /ps, file = 'jtprob.ps', $
                              xsize = 5.0, ysize = 4.0, /def, /jour
  setcolors,/sys
  plot, dvec/1d3, p, xtitle = 'Distance (kpc)', $
        ytitle = 'Probability (per 20 pc bin)',xcharsize=1.25,ycharsize=1.25

  oplot, dvec/1d3, p1, color = !d.table_size/2, line = 2
  oplot, dvec/1d3, p2, color = !d.table_size/2, line = 3
  oplot, dvec/1d3, p3, color = !d.table_size/2, line = 4
  oplot, dvec/1d3, p4, color = !red, line = 2, thick = !p.thick*3
  oplot, dvec/1d3, p4a, color = !blue, line = 2, thick = !p.thick*3
  legend, /right, /top, box = 0, ['Joint Probability', $
                                  'Position', $
                                  'Kinematic Distance', 'IRDC Association'], $
          line = [0, 2, 3, 4], $
          color = [!p.color, !d.table_size/2, $
                   !d.table_size/2, !d.table_size/2]
  if keyword_set(ps) then ps, /x

  pause = get_kbrd(1)
  endfor 

  return
end
